package com.example.educationplatformbackend.mapper;

import com.example.educationplatformbackend.domian.illustrations.Illustration;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IllustrationMapper {

    @Select("SELECT * FROM illustrations")
    List<Illustration> findAll();

    @Select("SELECT * FROM illustrations WHERE id = #{id}")
    Illustration findById(@Param("id") Long id);

    @Insert("INSERT INTO illustrations (src, title, avatar, author, likes) VALUES (#{src}, #{title}, #{avatar}, #{author}, #{likes})")
    void save(Illustration illustration);

    @Update("UPDATE illustrations SET src=#{src}, title=#{title}, avatar=#{avatar}, author=#{author}, likes=#{likes} WHERE id=#{id}")
    void updateIllustration(Illustration illustration);

    @Delete("DELETE FROM illustrations WHERE id = #{id}")
    void deleteById(@Param("id") Long id);
}
